/**
 * This is a generated class and is not intended for modfication.  To customize behavior
 * of this value object you may modify the generated sub-class of this class - Round.as.
 */

package valueObjects
{
import com.adobe.fiber.services.IFiberManagingService;
import com.adobe.fiber.valueobjects.IValueObject;
import flash.events.Event;
import flash.events.EventDispatcher;
import mx.collections.ArrayCollection;
import mx.events.PropertyChangeEvent;
import valueObjects.BettingRound;
import valueObjects.Card;
import valueObjects.Pot;

import flash.net.registerClassAlias;
import flash.net.getClassByAlias;
import com.adobe.fiber.core.model_internal;
import com.adobe.fiber.valueobjects.IPropertyIterator;
import com.adobe.fiber.valueobjects.AvailablePropertyIterator;

use namespace model_internal;

[ExcludeClass]
public class _Super_Round extends flash.events.EventDispatcher implements com.adobe.fiber.valueobjects.IValueObject
{
    model_internal static function initRemoteClassAliasSingle(cz:Class) : void 
    {
        try 
        {
            if (flash.net.getClassByAlias("engine.Round") == null)
            {
                flash.net.registerClassAlias("engine.Round", cz);
            } 
        }
        catch (e:Error) 
        {
            flash.net.registerClassAlias("engine.Round", cz); 
        }
    }   
     
    model_internal static function initRemoteClassAliasAllRelated() : void 
    {
        valueObjects.Card.initRemoteClassAliasSingleChild();
        valueObjects.Pot.initRemoteClassAliasSingleChild();
        valueObjects.Seat.initRemoteClassAliasSingleChild();
        valueObjects.Hand.initRemoteClassAliasSingleChild();
        valueObjects.Player.initRemoteClassAliasSingleChild();
        valueObjects.BettingRound.initRemoteClassAliasSingleChild();
    }

	model_internal var _dminternal_model : _RoundEntityMetadata;

	/**
	 * properties
	 */
	private var _internal_bigBlindPos : int;
	private var _internal_turn : valueObjects.Card;
	private var _internal_flop2 : valueObjects.Card;
	private var _internal_flop1 : valueObjects.Card;
	private var _internal_activePotIndex : int;
	private var _internal_flop3 : valueObjects.Card;
	private var _internal_activePot : valueObjects.Pot;
	private var _internal_allIn : Boolean;
	private var _internal_bettingRound : valueObjects.BettingRound;
	private var _internal_pocketsDealed : Boolean;
	private var _internal_communityCards : ArrayCollection;
	model_internal var _internal_communityCards_leaf:valueObjects.Card;
	private var _internal_smallBlindPos : int;
	private var _internal_pots : ArrayCollection;
	model_internal var _internal_pots_leaf:valueObjects.Pot;
	private var _internal_actualBettingRound : int;
	private var _internal_dealerPos : int;
	private var _internal_river : valueObjects.Card;

    private static var emptyArray:Array = new Array();

    /**
     * derived property cache initialization
     */  
    model_internal var _cacheInitialized_isValid:Boolean = false;   
    
	model_internal var _changeWatcherArray:Array = new Array();   

	public function _Super_Round() 
	{	
		_model = new _RoundEntityMetadata(this);
	
		// Bind to own data properties for cache invalidation triggering  
       
	}

    /**
     * data property getters
     */
	[Bindable(event="propertyChange")] 
    public function get bigBlindPos() : int    
    {
            return _internal_bigBlindPos;
    }    
	[Bindable(event="propertyChange")] 
    public function get turn() : valueObjects.Card    
    {
            return _internal_turn;
    }    
	[Bindable(event="propertyChange")] 
    public function get flop2() : valueObjects.Card    
    {
            return _internal_flop2;
    }    
	[Bindable(event="propertyChange")] 
    public function get flop1() : valueObjects.Card    
    {
            return _internal_flop1;
    }    
	[Bindable(event="propertyChange")] 
    public function get activePotIndex() : int    
    {
            return _internal_activePotIndex;
    }    
	[Bindable(event="propertyChange")] 
    public function get flop3() : valueObjects.Card    
    {
            return _internal_flop3;
    }    
	[Bindable(event="propertyChange")] 
    public function get activePot() : valueObjects.Pot    
    {
            return _internal_activePot;
    }    
	[Bindable(event="propertyChange")] 
    public function get allIn() : Boolean    
    {
            return _internal_allIn;
    }    
	[Bindable(event="propertyChange")] 
    public function get bettingRound() : valueObjects.BettingRound    
    {
            return _internal_bettingRound;
    }    
	[Bindable(event="propertyChange")] 
    public function get pocketsDealed() : Boolean    
    {
            return _internal_pocketsDealed;
    }    
	[Bindable(event="propertyChange")] 
    public function get communityCards() : ArrayCollection    
    {
            return _internal_communityCards;
    }    
	[Bindable(event="propertyChange")] 
    public function get smallBlindPos() : int    
    {
            return _internal_smallBlindPos;
    }    
	[Bindable(event="propertyChange")] 
    public function get pots() : ArrayCollection    
    {
            return _internal_pots;
    }    
	[Bindable(event="propertyChange")] 
    public function get actualBettingRound() : int    
    {
            return _internal_actualBettingRound;
    }    
	[Bindable(event="propertyChange")] 
    public function get dealerPos() : int    
    {
            return _internal_dealerPos;
    }    
	[Bindable(event="propertyChange")] 
    public function get river() : valueObjects.Card    
    {
            return _internal_river;
    }    

    /**
     * data property setters
     */      
    public function set bigBlindPos(value:int) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:int = _internal_bigBlindPos;               
        if (oldValue !== value)
        {
            _internal_bigBlindPos = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "bigBlindPos", oldValue, _internal_bigBlindPos));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set turn(value:valueObjects.Card) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_turn == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:valueObjects.Card = _internal_turn;               
        if (oldValue !== value)
        {
            _internal_turn = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "turn", oldValue, _internal_turn));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set flop2(value:valueObjects.Card) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_flop2 == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:valueObjects.Card = _internal_flop2;               
        if (oldValue !== value)
        {
            _internal_flop2 = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "flop2", oldValue, _internal_flop2));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set flop1(value:valueObjects.Card) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_flop1 == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:valueObjects.Card = _internal_flop1;               
        if (oldValue !== value)
        {
            _internal_flop1 = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "flop1", oldValue, _internal_flop1));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set activePotIndex(value:int) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:int = _internal_activePotIndex;               
        if (oldValue !== value)
        {
            _internal_activePotIndex = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "activePotIndex", oldValue, _internal_activePotIndex));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set flop3(value:valueObjects.Card) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_flop3 == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:valueObjects.Card = _internal_flop3;               
        if (oldValue !== value)
        {
            _internal_flop3 = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "flop3", oldValue, _internal_flop3));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set activePot(value:valueObjects.Pot) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_activePot == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:valueObjects.Pot = _internal_activePot;               
        if (oldValue !== value)
        {
            _internal_activePot = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "activePot", oldValue, _internal_activePot));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set allIn(value:Boolean) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:Boolean = _internal_allIn;               
        if (oldValue !== value)
        {
            _internal_allIn = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "allIn", oldValue, _internal_allIn));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set bettingRound(value:valueObjects.BettingRound) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_bettingRound == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:valueObjects.BettingRound = _internal_bettingRound;               
        if (oldValue !== value)
        {
            _internal_bettingRound = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "bettingRound", oldValue, _internal_bettingRound));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set pocketsDealed(value:Boolean) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:Boolean = _internal_pocketsDealed;               
        if (oldValue !== value)
        {
            _internal_pocketsDealed = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "pocketsDealed", oldValue, _internal_pocketsDealed));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set communityCards(value:*) : void
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_communityCards == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:ArrayCollection = _internal_communityCards;               
        if (oldValue !== value)
        {
            if (value is ArrayCollection)
            {
                _internal_communityCards = value;
            }
            else if (value is Array)
            {
                _internal_communityCards = new ArrayCollection(value);
            }
            else
            {
                throw new Error("value of communityCards must be a collection");
            }
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "communityCards", oldValue, _internal_communityCards));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set smallBlindPos(value:int) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:int = _internal_smallBlindPos;               
        if (oldValue !== value)
        {
            _internal_smallBlindPos = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "smallBlindPos", oldValue, _internal_smallBlindPos));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set pots(value:*) : void
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_pots == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:ArrayCollection = _internal_pots;               
        if (oldValue !== value)
        {
            if (value is ArrayCollection)
            {
                _internal_pots = value;
            }
            else if (value is Array)
            {
                _internal_pots = new ArrayCollection(value);
            }
            else
            {
                throw new Error("value of pots must be a collection");
            }
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "pots", oldValue, _internal_pots));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set actualBettingRound(value:int) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:int = _internal_actualBettingRound;               
        if (oldValue !== value)
        {
            _internal_actualBettingRound = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "actualBettingRound", oldValue, _internal_actualBettingRound));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set dealerPos(value:int) : void 
    {    	
        var recalcValid:Boolean = false;
    	
    	
    	var oldValue:int = _internal_dealerPos;               
        if (oldValue !== value)
        {
            _internal_dealerPos = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "dealerPos", oldValue, _internal_dealerPos));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    
    public function set river(value:valueObjects.Card) : void 
    {    	
        var recalcValid:Boolean = false;
    	if (value == null || _internal_river == null)
    	{
    		recalcValid = true;
    	}	
    	
    	
    	var oldValue:valueObjects.Card = _internal_river;               
        if (oldValue !== value)
        {
            _internal_river = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "river", oldValue, _internal_river));
        }    	     
        
        if (recalcValid && model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }  
    }    

    /**
     * data property setter listeners
     */   

   model_internal function setterListenerAnyConstraint(value:flash.events.Event):void
   {
        if (model_internal::_cacheInitialized_isValid)
        {
            model_internal::isValid_der = model_internal::calculateIsValid();
        }        
   }   

    /**
     * valid related derived properties
     */
    model_internal var _isValid : Boolean;
    model_internal var _invalidConstraints:Array = new Array();
    model_internal var _validationFailureMessages:Array = new Array();

    /**
     * derived property calculators
     */

    /**
     * isValid calculator
     */
    model_internal function calculateIsValid():Boolean
    {
        var violatedConsts:Array = new Array();    
        var validationFailureMessages:Array = new Array();    

		if (_model.isTurnAvailable && _internal_turn == null)
		{
			violatedConsts.push("turnIsRequired");
			validationFailureMessages.push("turn is required");
		}
		if (_model.isFlop2Available && _internal_flop2 == null)
		{
			violatedConsts.push("flop2IsRequired");
			validationFailureMessages.push("flop2 is required");
		}
		if (_model.isFlop1Available && _internal_flop1 == null)
		{
			violatedConsts.push("flop1IsRequired");
			validationFailureMessages.push("flop1 is required");
		}
		if (_model.isFlop3Available && _internal_flop3 == null)
		{
			violatedConsts.push("flop3IsRequired");
			validationFailureMessages.push("flop3 is required");
		}
		if (_model.isActivePotAvailable && _internal_activePot == null)
		{
			violatedConsts.push("activePotIsRequired");
			validationFailureMessages.push("activePot is required");
		}
		if (_model.isBettingRoundAvailable && _internal_bettingRound == null)
		{
			violatedConsts.push("bettingRoundIsRequired");
			validationFailureMessages.push("bettingRound is required");
		}
		if (_model.isCommunityCardsAvailable && _internal_communityCards == null)
		{
			violatedConsts.push("communityCardsIsRequired");
			validationFailureMessages.push("communityCards is required");
		}
		if (_model.isPotsAvailable && _internal_pots == null)
		{
			violatedConsts.push("potsIsRequired");
			validationFailureMessages.push("pots is required");
		}
		if (_model.isRiverAvailable && _internal_river == null)
		{
			violatedConsts.push("riverIsRequired");
			validationFailureMessages.push("river is required");
		}

		var styleValidity:Boolean = true;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
    
        model_internal::_cacheInitialized_isValid = true;
        model_internal::invalidConstraints_der = violatedConsts;
        model_internal::validationFailureMessages_der = validationFailureMessages;
        return violatedConsts.length == 0 && styleValidity;
    }  

    /**
     * derived property setters
     */

    model_internal function set isValid_der(value:Boolean) : void
    {
       	var oldValue:Boolean = model_internal::_isValid;               
        if (oldValue !== value)
        {
        	model_internal::_isValid = value;
        	_model.model_internal::fireChangeEvent("isValid", oldValue, model_internal::_isValid);
        }        
    }

    /**
     * derived property getters
     */

    [Transient] 
	[Bindable(event="propertyChange")] 
    public function get _model() : _RoundEntityMetadata
    {
		return model_internal::_dminternal_model;              
    }	
    
    public function set _model(value : _RoundEntityMetadata) : void       
    {
    	var oldValue : _RoundEntityMetadata = model_internal::_dminternal_model;               
        if (oldValue !== value)
        {
        	model_internal::_dminternal_model = value;
        	this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "_model", oldValue, model_internal::_dminternal_model));
        }     
    }      

    /**
     * methods
     */  


    /**
     *  services
     */                  
     private var _managingService:com.adobe.fiber.services.IFiberManagingService;
    
     public function set managingService(managingService:com.adobe.fiber.services.IFiberManagingService):void
     {
         _managingService = managingService;
     }                      
     
    model_internal function set invalidConstraints_der(value:Array) : void
    {  
     	var oldValue:Array = model_internal::_invalidConstraints;
     	// avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_invalidConstraints = value;   
			_model.model_internal::fireChangeEvent("invalidConstraints", oldValue, model_internal::_invalidConstraints);   
        }     	             
    }             
    
     model_internal function set validationFailureMessages_der(value:Array) : void
    {  
     	var oldValue:Array = model_internal::_validationFailureMessages;
     	// avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_validationFailureMessages = value;   
			_model.model_internal::fireChangeEvent("validationFailureMessages", oldValue, model_internal::_validationFailureMessages);   
        }     	             
    }        
     
     // Individual isAvailable functions     
	// fields, getters, and setters for primitive representations of complex id properties

}

}
